package com.example.smssender;

import java.io.Serializable;

/**
 * 短信发送状态数据模型
 */
public class SendingStatus implements Serializable {
    public static final int STATUS_PENDING = 0;      // 待发送
    public static final int STATUS_SENDING = 1;      // 发送中
    public static final int STATUS_SUCCESS = 2;     // 成功
    public static final int STATUS_FAILED = 3;       // 失败
    
    private String phoneNumber;
    private String contactName;
    private int status;
    private String errorMsg;
    private int partIndex = -1;      // 分片索引（长短信）
    private int totalParts = 1;      // 总分片数
    
    public SendingStatus() {
    }
    
    public SendingStatus(String phoneNumber, String contactName) {
        this.phoneNumber = phoneNumber;
        this.contactName = contactName;
        this.status = STATUS_PENDING;
    }
    
    public String getPhoneNumber() {
        return phoneNumber;
    }
    
    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }
    
    public String getContactName() {
        return contactName;
    }
    
    public void setContactName(String contactName) {
        this.contactName = contactName;
    }
    
    public int getStatus() {
        return status;
    }
    
    public void setStatus(int status) {
        this.status = status;
    }
    
    public String getErrorMsg() {
        return errorMsg;
    }
    
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
    
    public int getPartIndex() {
        return partIndex;
    }
    
    public void setPartIndex(int partIndex) {
        this.partIndex = partIndex;
    }
    
    public int getTotalParts() {
        return totalParts;
    }
    
    public void setTotalParts(int totalParts) {
        this.totalParts = totalParts;
    }
    
    /**
     * 获取状态文本描述
     */
    public String getStatusText() {
        switch (status) {
            case STATUS_PENDING:
                return "待发送";
            case STATUS_SENDING:
                return "发送中";
            case STATUS_SUCCESS:
                return "成功";
            case STATUS_FAILED:
                return "失败";
            default:
                return "未知";
        }
    }
    
    /**
     * 获取显示名称（优先显示联系人姓名，否则显示手机号）
     */
    public String getDisplayName() {
        if (contactName != null && !contactName.trim().isEmpty()) {
            return contactName;
        }
        return phoneNumber != null ? phoneNumber : "未知";
    }
}

